var breakpoint = 800; $(document).ready(function(e){ // roller(); graphp1(); // resize(); $('.linked,.values2').mouseenter(function(e){ e.preventDefault(); var c = $(this).data('name'); $(this).addClass('active').siblings().removeClass('active'); $('.'+c).addClass('active').siblings().removeClass('active'); $($(this).attr('href')).addClass('active').siblings().removeClass('active'); }); $('.linked,.values2').click(function(e){ e.preventDefault(); var c = $(this).data('name'); $(this).addClass('active').siblings().removeClass('active'); $('.'+c).addClass('active').siblings().removeClass('active'); $($(this).attr('href')).addClass('active').siblings().removeClass('active'); }); $('.pie').mouseleave(function(){ $(this).find('.default').addClass('active').siblings().removeClass('active'); }); }) function graphp1(){ // if class normal add next to .graph1 normal = every columns from zero ,no class(default) = stack destack ,negative = from_zero_chart but negative enabled $('.graph1').each(function(e){ var t = $(this); var r = t.data('rowsize'); var m = t[0].hasAttribute('data-margin') ? t.data('margin') : 0; var count = t.find('.col').length; var divid = 100 - parseInt(m); var w = divid/count - (divid/10)/count; var margin = (divid/10)/count; var stack = 0; var h = 0 var heightOfRow = t.find(".row").css("height") heightOfRow = parseInt(heightOfRow.slice(0,heightOfRow.length-2)) var destack = 0; var little = false; var negative = false; var m = 2.5*(20/r); var from_zero_chart = false; if (this.classList.contains("little")){ little = true; } if (this.classList.contains("negative")){ var negative = true; } if (this.classList.contains("normal")){ var from_zero_chart = true; } var pocet_zapornych_riadkov = 0; t.find('.line').each(function(i,e){ if (parseInt(e.firstChild.innerHTML) < 0){ pocet_zapornych_riadkov++ } }) var small_chart = true; if (this.classList.contains("bigchart")){ small_chart = false; } t.find('.col').each(function(i,e){ if (small_chart){ var l = 10+(i*(80/count+1)); // margin + w = divid/count }else{ var l = (7.14+(i*(80/count+1))); // margin + w = divid/count } if (negative){ var b = heightOfRow + pocet_zapornych_riadkov *50 // 50 weight of the line }else{ var b = heightOfRow } var h = $(e).find('span').text(); if (h.slice(h.length-1,h.length+1) == "%"){ h = h.slice(0,h.length-1); } h = h*m; var nx = $(e).find('span').text();//$(e).hasClass('pipe') ? Math.abs($(e).find('span').text()) : $(e).find('span').text(); $(e).find('span').text(nx.toString().replace(/\B(?=(\d{3})+(?!\d))/g, ",")); //console.log('val: '+$(e).find('span').text()+', h: '+h); if($(e).hasClass('stack')){ if(h<0){ b += stack+h; } else { b += stack; } if (!from_zero_chart){ stack += h; } } else { if (stack < 0){ b += stack; h = -stack }else{ h = stack } } let kof = 0 let vyska_column = h*(r/50)+(b-heightOfRow)*(r/50) let do_ciary = (h*(r/50)+(b-heightOfRow)*(r/50)) % r if (r - do_ciary > 38){ kof = -(r - do_ciary) - 15 +"px" }else{ kof = -30+"px"; } // if (((h*(r/50))+(b-heightOfRow)*(r/50)) % 50 >= 25){ // kof += 10; // } $(e).find('span').css("top", kof+"px"); var h = Math.abs(h); if (little){ $(e).css({'width':16+'px', 'bottom': b+'px', 'height' : h-1+'px', 'left' : (l)+'%'}); }else{ $(e).css({'width':16+'px', 'bottom': b+'px', 'height' : h-1+'px', 'left' : l+'%'}); } }); t.find('.row').children().each(function(i,e){ if (t.hasClass("bigchart")){ var l = 6.14+(i*(80/count+1)); // margin + w = divid/count }else{ var l = 7.5+(i*(80/count+1)); // margin + w = divid/count } if (little){ var l = (7.5+(i*(80/count+1))) } var b = 41; $(e).css({'width':w+2+'%', 'left' : l-1+'%'}); }); t.find('.value').each(function(i,e){ var b = 41; $(e).css({'width':50+'px', 'bottom': b+'px', 'height' : h-1+'px', 'left' : l+'%'}); }) // for (let i = Math.round(stack_array/100)+1;i>-(Math.round(stack_array/100))-2;i--){ // var span = document.createElement("span"); // var div = document.createElement("div"); // div.style.height = ((r/2)*m)-1+"px"; // div.style.paddingTop = ((r/2)*m)+"px"; // span.innerHTML = toString(i * 100); // div.appendChild(span) // // t.insertBefore(div, t.firstChild) // // } t.find('.line').css({'height': ((r/2)*m)-1+'px','padding-top': ((r/2)*m)+'px'}); }); }